

texture g_src_color_tex;


sampler2D g_src_color_sampler = sampler_state
{
    Texture = <g_src_color_tex>;
    AddressU = Clamp;
    AddressV = Clamp;
    MinFilter = Point;
    MagFilter = Linear;
    MipFilter = Linear;
};

static const int g_kernel_size = 13;

float2 pixel_kernel[g_kernel_size] =
{
    { -6, 0 },
    { -5, 0 },
    { -4, 0 },
    { -3, 0 },
    { -2, 0 },
    { -1, 0 },
    {  0, 0 },
    {  1, 0 },
    {  2, 0 },
    {  3, 0 },
    {  4, 0 },
    {  5, 0 },
    {  6, 0 },
};

float2 texel_kernel[g_kernel_size]
<
    string ConvertPixelsToTexels = "pixel_kernel";
>;

static const float blur_weights[g_kernel_size] = 
{
    0.002216,
    0.008764,
    0.026995,
    0.064759,
    0.120985,
    0.176033,
    0.199471,
    0.176033,
    0.120985,
    0.064759,
    0.026995,
    0.008764,
    0.002216,
};

//-----------------------------------------------------------------------------
// Pixel Shader: HorizontalBlur
// Desc: Blurs the image horizontally
//-----------------------------------------------------------------------------
float4 post_process_ps( float2 uv : TEXCOORD0 ) : COLOR0
{
    float4 color = 0;

    for (int i = 0; i < g_kernel_size; ++i)
    {    
        color += tex2D(g_src_color_sampler, uv + texel_kernel[i].xy ) * blur_weights[i];
    }
    
    return color;
}

//-----------------------------------------------------------------------------
// Technique: PostProcess
// Desc: Performs post-processing effect that converts a colored image to
//       black and white.
//-----------------------------------------------------------------------------
technique post_process_tech
{
    pass p0
    {
        VertexShader = null;
        PixelShader = compile ps_2_0 post_process_ps();
        ZEnable = false;
    }
}
